package type.proxy;

import java.lang.reflect.Proxy;

/**
 * @Date 2021/5/2 10:43 上午
 * @Author dengxin
 */
public class DynamicProxyTest {

    public static void consume(DoSomething doSomething) {
        doSomething.doSomething();
        doSomething.doSomethingElse("Dynamic Proxy ");
    }

    public static void main(String[] args) {
        RealObject object = new RealObject();
        consume(object);
        DoSomething proxy = (DoSomething) Proxy.newProxyInstance(DoSomething.class.getClassLoader(),
                new Class[]{DoSomething.class}, new DynamicProxyHandler(object));
        consume(proxy);
    }
}
